import cn.idev.excel.context.AnalysisContext;
import cn.idev.excel.read.listener.ReadListener;
import com.alibaba.fastjson.JSON;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: zhuang
 * @Date: 2024/12/31 10:02
 * @Description: TODO
 * @Version: 1.0
 **/

// 实现 ReadListener 接口，设置读取数据的操作
@Getter
public class DemoDataListener implements ReadListener<DemoData> {

    private List<DemoData> dataList = new ArrayList<>();
    @Override
    public void invoke(DemoData data, AnalysisContext context) {
        System.out.println("解析到一条数据" + JSON.toJSONString(data));
        dataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        System.out.println("所有数据解析完成！");
    }
}

